<%@page contentType="text/html; charset=utf-8"%>
<script type="text/javascript" src="../../components/jscommons/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		dispalyAssessors();
		createFormCode();
	});
	
	function dispalyAssessors(){
		jQuery.post("/finance/workflow/queryAssessors.do",{userId:userId,companeyCode:companeyCode},function(str){
			var data = eval('(' + str + ')');
			var htmltxtcontent = "";
			for (var i=0; i<data.data.length; i++) {
				htmltxtcontent +='<input type="checkbox" name="assessor_'+data.data[i].assessorId+'" id="assessor_'+data.data[i].assessorId+'" value="'+data.data[i].assessorId+'"/>&nbsp;'+data.data[i].assessorName+'&nbsp;&nbsp;&nbsp;';
			}
			//alert(htmltxtcontent);
			$("#assessors_inputs_span").html(htmltxtcontent);
        });
	}
	function createFormCode(){
		jQuery.post("/finance/workflow/createFormCode.do",{prefixStr:"S"},function(str){
			var data = eval('(' + str + ')');
			$("#formcode_hidden_id").val(data.formCode);
			var htmltxtcontent = data.formCode;
			$("#formcode_span_id").html(htmltxtcontent);
        });
	}
	function createApply(){
		jQuery.post("/finance/workflow/createApply.do",{formCode:$("#formcode_hidden_id").val(),workflowName:$("#workflowName").val(),workflowDescription:$("#workflowDescription").text(),applicantId:1,assessorIds:getAssessorCheckboxs(),companyCode:1,nodeName:"事件申请节点"},function(str){
			var data = eval('(' + str + ')');
			if(data.success){
				alert("该申请已提交");
			}
        });
	}	
	
	function getAssessorCheckboxs(){
		var ids = "";
		var intL = $("#assessorIds_checkboxs input:checked").length;
		if(intL != 0){
			$("#assessorIds_checkboxs input[type=checkbox]").each(function(index){
				if(this.checked){
					ids += this.value + ",";
				}
			});
		}
		if(ids.length!=0){
			ids = ids.substring(0,ids.length-1);
		}
		return ids;
	}
</script>
<div id="rightsiber">
	<h1>
		业务审批
	</h1>
	<div class="titer">
		1.事件审批>>A、申请页面
	</div>
	<form id="createapply_form" action="" method="post" >
	<input type="hidden" name="applicantId" id="applicantId" value="1"/>
	<input type="hidden" name="formcode" id="formcode_hidden_id"/>
	
		<table class="form" width="800" border="0" cellspacing="0"
			cellpadding="0">
			<tr>
				<td width="150" height="50" align="right" valign="middle">
					<p>
						单号：
					</p>
				</td>
				<td align="left" valign="middle">
					<label>
						<span id="formcode_span_id"></span>
					</label>
				</td>
			</tr>
			<tr>
				<td width="150" height="50" align="right" valign="middle">
					<p>
						申请名称：
					</p>
				</td>
				<td align="left" valign="middle">
					<label>
						<input class="inputa" type="text" name="workflowName" id="workflowName" />
					</label>
					<span>请输入 至少6个字符</span>
				</td>
			</tr>
			<tr>
				<td width="150" height="50" align="right" valign="top">
					<p>
						事件描述：
					</p>
				</td>
				<td align="left" valign="middle">
					<label>
						<textarea name="workflowDescription" id="workflowDescription" cols="45" rows="5"></textarea>
					</label>
				</td>
			</tr>
			
			<tr>
				<td width="150" height="50" align="right" valign="middle">
					<p>
						审核人：
					</p>
				</td>
				<td align="left" valign="middle" id="assessorIds_checkboxs" >
					<label id="assessors_inputs_span">
					</label>
				</td>
			</tr>
			<tr>
				<td width="150" height="50" align="right" valign="middle">
					&nbsp;
				</td>
				<td align="left" valign="middle">
					<label>
						<input type="button" name="button" id="button" class="inputb" value="提交"  onclick="createApply();"/>
						<input type="reset" name="button2" id="button2" class="inputb" value="重置" />
					</label>
				</td>
			</tr>
		</table>
	</form>
</div>